gtk/gtkcssenumvalue.c: Deal with __builtin_popcount on MSVC
authorChun-wei Fan <fanchunwei@src.gnome.org>
Tue, 24 Oct 2017 08:16:08 +0000 (16:16 +0800)
committerChun-wei Fan <fanchunwei@src.gnome.org>
Tue, 24 Oct 2017 16:53:37 +0000 (00:53 +0800)
commit20fc576275fc4df0fb33fd0dc24c799bef512b79
tree9638080872af42eedfd9cbc154f799967d7ff0da
parent5b9177f53b62c2a2123edbbf541da12e1c6b700b
gtk/gtkcssenumvalue.c: Deal with __builtin_popcount on MSVC

__builtin_popcount is a GCCism that is used to count the number of bits
involved, which means any non GCC/CLang compilers won't like the code,
meaning that on MSVC builds we must implement it ourselves.

We first use __cpuid() to check whether the CPU supports the popcount
instruction, if it does, we use the __popcnt intrinsic, otherwise
(untested, since I don't have a system that does not have the
instruction), we use the suggested hacks at
http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel

https://bugzilla.gnome.org/show_bug.cgi?id=773299
gtk/gtkcssenumvalue.c